package repository.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import repository.CategoryRepository;
import domain.Category;


@Repository
public class CategoryRepositoryImpl extends AbstractHibernateRepository<Category> implements CategoryRepository{

	@Autowired
	public CategoryRepositoryImpl(SessionFactory session){
		super(session);
	}

	public Category getCategory(int id) {
		return get(Category.class, id);
	}

	public List<Category> getCategories() {
		String hql = "FROM Category";
		List<Category> result = find(hql);
		return result.size() > 0 ? result : null;
	}
}
